----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 66264 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 1024
SPELL.m_sName = "FIre Blast"
SPELL.m_sToolTip =	[[Blast the target with fire.
					Deals extra damage if the target
					is burning.]]
SPELL.m_sIcon = "devin/blackbetty/spells/mage/fireblast.png"
SPELL.m_iCoolDown = 1
SPELL.m_iManaCost = 50
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_MAA
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

local range = 100

function SPELL:Cast( pl, target )
	
	print(self.m_sName)
	if(target && target:IsValid() && target != pl ) then
		pl.InSpellAnimation = true
		if(pl:IsPlayer())then
			pl:DoAnimationEvent(ACT_HL2MP_GESTURE_RANGE_ATTACK_KNIFE)
		else
			pl:DoAnimationEvent(ACT_HL2MP_GESTURE_RANGE_ATTACK_KNIFE)
		end
		pl:EmitSound("devin/blackbetty/weapons/castsounds/FireCast.wav", 150, 80+math.random(10,20))
		ParticleEffectAttach( "fire_hands_instacast", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("anim_attachment_RH"))
			timer.Simple(0.15, function()
				if(target and pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
					self:Effect(pl, target)
					--self:ApplySpellMods(self, pl, target)
				end
			end)
	end
end

function SPELL:Effect(pl, target)

	local weapon = nil
	local isburning = false
	
	if(target.Effects)then
		for k, v in ipairs(target.Effects)do
			if(v.effectName == ""..pl:GetName().."Burned")then
				isburning = true
				break
			end
		end
	end
	
	if(pl:IsPlayer())then
		weapon = pl:GetWeapon("weapon_all")
	else
		target = pl.Target
	end
	
	if(isburning)then
		self:DealDamage(weapon.MinWeaponDamage*2+15, weapon.MaxWeaponDamage*2+15, pl, target, DMG_BURN)
	else
		self:DealDamage(weapon.MinWeaponDamage*2, weapon.MaxWeaponDamage*2, pl, target, DMG_BURN)
	end
	
	pl:EmitSound("devin/blackbetty/weapons/hit/Fire1.wav", 150, 80+math.random(10,20))
	ParticleEffect( "impact_firebig", target:GetPos() + Vector(0, 0, 32), Angle(0,0,0), pl )
end




